import java.awt.image.BufferedImage;

//英雄机
public class Hero extends FlyingObject{
    int score;            //分数
    int doubleFireTime;   //双倍子弹剩余时间
    Bullet[] bs;


    Hero(){
        health=3;
        x=150;
        y=400;

        image=ImageFiler.heroplane;
        imageWidth=image.getWidth();
        imageHeight=image.getHeight();
    }

    //记录图片变化次数
    private int count = 0;
    private BufferedImage[] heroImage = {ImageFiler.heroplane,ImageFiler.heroplane1};
    @Override
    public void move() {
        //图片的切换
        count++;
        //方式一:
        if(count % 2 == 0){
            setImage(ImageFiler.heroplane);
        }else {
            setImage(ImageFiler.heroplane1);
        }
        //方式二:
//        setImage(heroImage[count % 2]);

    }


    public Bullet[]  shoot() {
        Bullet[] bs = {};
        if(doubleFireTime ==0) {
            bs = new Bullet[1];
            bs[0] = new Bullet( x+imageWidth/2-4,y-14);
        }else {
            bs =new Bullet[2];
            bs[0] = new Bullet(x+imageWidth/4-4,y-14);
            bs[1] = new Bullet(x+imageWidth*3/4-4,y-14);
            doubleFireTime -= 2;
        }
        return bs;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }
}
